package o;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.AbsListView;
import com.huawei.appgallery.forum.base.https.jgw.JGWTabDetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean.a;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import java.lang.ref.WeakReference;
import java.util.List;

public class Type2ListSegment extends BaseListSegment {
    private d ʼॱ;
    private int ʽॱ;
    private String ʾ;
    private int ˈ = 0;
    private boolean ॱˋ = false;
    private int ॱˎ = 1;
    private String ᐝॱ;

    static class d extends SafeBroadcastReceiver {
        private final Runnable ˊ = new a();
        private WeakReference<Type2ListSegment> ˋ;

        static class a implements Runnable {
            private a() {
            }

            public void run() {
                evn ˎ = evr.ˊ().ˎ();
                if (ˎ != null) {
                    ˎ.ʼ();
                }
            }
        }

        public d(Type2ListSegment o_bsr) {
            this.ˋ = new WeakReference(o_bsr);
        }

        public void onReceiveMsg(Context context, Intent intent) {
            String action = intent.getAction();
            Type2ListSegment o_bsr = (Type2ListSegment) this.ˋ.get();
            if (action != null && !action.isEmpty() && "android.net.conn.CONNECTIVITY_CHANGE".equals(action)) {
                ˊ(o_bsr, context);
            }
        }

        private void ˊ(Type2ListSegment o_bsr, Context context) {
            int ˊ = doo.ˊ(((ConnectivityManager) ContentManager.getInstant().getContext().getSystemService("connectivity")).getActiveNetworkInfo());
            if (ˊ != o_bsr.ʽॱ) {
                o_bsr.ʽॱ = ˊ;
                Handler handler = new Handler(context.getMainLooper());
                if (doo.ˊ(context)) {
                    handler.removeCallbacks(this.ˊ);
                    evn ˎ = evr.ˊ().ˎ();
                    if (ˎ != null) {
                        ˎ.ʼ();
                        return;
                    }
                    return;
                }
                handler.postDelayed(this.ˊ, 2000);
            }
        }
    }

    protected void ͺ() {
        Bundle ˊˊ = ˊˊ();
        if (ˊˊ != null) {
            this.ˊ = ˊˊ.getString("SEGMENT_URI");
            this.ͺ = ˊˊ.getString("APPID");
            this.ॱ = ˊˊ.getBoolean("IS_DATA_READY", false);
            this.ᐝॱ = ˊˊ.getString("DOMAINID");
            this.ॱˋ = ˊˊ.getBoolean("IS_TAB_PAGE");
        } else {
            bqx.ॱ("ForumSegment", "parserArguments, arguments is null");
        }
        ˏॱ();
    }

    protected void ˊˋ() {
        this.ʽॱ = doo.ˊ(((ConnectivityManager) ContentManager.getInstant().getContext().getSystemService("connectivity")).getActiveNetworkInfo());
    }

    public void ˊᐝ() {
        this.ʼ = -1;
        ˎ(1);
        ˎ(false);
        if (this.ᐝ != null) {
            int ˊॱ = this.ᐝ.ˊॱ();
            if (this.ॱˋ && ˊॱ == 0) {
                ˍ();
                this.mLoadCtrl.ॱ();
            }
        }
        ˋ();
    }

    private void ˍ() {
        ˊ(false);
        ˏ(false);
    }

    protected cia ˋ(Context context) {
        return new chl(context);
    }

    public void ॱ(bgq o_bgq, List<cvs> list) {
        if (this.ᐝ == null) {
            bqx.ˊ("ForumSegment", "provider == null");
            ˋ(this.ॱᐝ);
        } else if (this.ᐝ.ˊॱ() == 0) {
            ˎ(1);
            this.ʾ = "";
        }
        if (ˋˊ() == 1) {
            this.ʾ = "";
        }
        list.add(new e(this.ˊ).ॱ(this.ͺ).ˏ(bsv.ॱ(this.ᐝॱ)).ॱ(this.ॱˎ).ˋ(this.ʾ).ॱ());
        if (this.mListView != null) {
            this.mListView.setmPullRefreshing(true);
        }
    }

    public boolean ॱ(bgq o_bgq, bgq.e eVar) {
        if (this.mListView != null) {
            this.mListView.setmPullRefreshing(false);
        }
        return super.ॱ(o_bgq, eVar);
    }

    public View ˋॱ() {
        super.ˋॱ();
        ˊˋ();
        return this.ˏ;
    }

    public void ˋ(int i) {
        super.ˋ(i);
        ˋˋ();
    }

    protected void ˏ(BaseRequest o_cvu, ResponseBean responseBean) {
        if (!(ʼ() || this.mLoadCtrl == null)) {
            this.mLoadCtrl.ॱ(0, 0);
            ˊ(true);
            this.mLoadCtrl = null;
        }
        ˎ(true);
        ˋ(responseBean.getResponseType() == a.FROM_CACHE);
        if (responseBean instanceof JGWTabDetailResponse) {
            JGWTabDetailResponse jGWTabDetailResponse = (JGWTabDetailResponse) responseBean;
            refreshTitle(jGWTabDetailResponse.ˋ());
            this.ʾ = jGWTabDetailResponse.ˊ();
            this.ᐝॱ = jGWTabDetailResponse.ᐝ();
        }
        if (this.mListView != null) {
            this.mListView.setEnableChangeLoadingView(responseBean.getResponseType() != a.UPDATE_CACHE);
        }
        ˊ(o_cvu, responseBean);
        if (this.ᐝ == null || this.ᐝ.ˊॱ() <= 0) {
            ʼ(false);
        } else {
            ʼ(true);
        }
        ˋˋ();
    }

    protected void ˊ(BaseRequest o_cvu, ResponseBean responseBean) {
        if (o_cvu instanceof bri) {
            bri o_bri = (bri) o_cvu;
            if ((this.ᐝ instanceof chl) && o_bri.ˎ() == 1 && (responseBean instanceof BaseDetailResponse)) {
                chl o_chl = (chl) this.ᐝ;
                o_chl.ˊ((BaseDetailResponse) responseBean);
                o_chl.ॱ(o_cvu);
            }
            bqx.ˊ("ForumSegment", "request.type: " + o_cvu.getRequestType() + ", response.type = " + responseBean.getResponseType() + ", reqPageNum = " + ˋˊ());
            if (ˋˊ() == 1) {
                this.ᐝ.ॱॱ();
            }
            if ((o_bri instanceof brm) && (responseBean instanceof JGWTabDetailResponse)) {
                bsi.ॱ.ˎ(this.ᐝ, o_cvu, responseBean);
            }
            if (ˋˊ() == 1 && this.mListView != null) {
                this.mListView.setSelection(0);
            }
            if (this.ᐝ.ᐝ() && responseBean.getResponseType() != a.FROM_CACHE) {
                ˎ(ˋˊ() + 1);
                return;
            }
            return;
        }
        bqx.ॱ("ForumSegment", "req is not instanceof BaseSecretRequest");
    }

    public int ˋˊ() {
        return this.ॱˎ;
    }

    public void ˎ(int i) {
        this.ॱˎ = i;
    }

    private void ʽ(boolean z) {
        if (z) {
            this.ˏ.setVisibility(0);
        } else {
            this.ˏ.setVisibility(8);
        }
    }

    public void onStop() {
        super.onStop();
        if (this.ॱˋ) {
            ʽ(false);
        }
        evr.ˊ().ᐝ();
        evr.ˊ().ʻ();
    }

    public void onResume() {
        super.onResume();
        if (this.ॱˋ && ˈ()) {
            ʽ(true);
        }
        ˋᐝ();
    }

    public cia ˌ() {
        return this.ᐝ;
    }

    public void ʼ(boolean z) {
        ˊ(z);
        ˏ(!z);
        if (this.mLoadCtrl == null) {
            return;
        }
        if (z) {
            this.mLoadCtrl.ˏ();
        } else {
            this.mLoadCtrl.ˋ();
        }
    }

    protected void ˋᐝ() {
        if (ˈ()) {
            evr.ˊ().ˎ(this.mListView);
        }
    }

    public void onScrollStateChanged(AbsListView absListView, int i) {
        super.onScrollStateChanged(absListView, i);
        this.ˈ = i;
        if (i == 0) {
            ˋᐝ();
        }
    }

    public void onScroll(AbsListView absListView, int i, int i2, int i3) {
        this.mListView.setVerticalScrollBarEnabled(false);
        evr.ˊ().ॱ(this.ˈ);
    }

    protected void ˋˋ() {
        evr.ˊ().ˋ(this.mListView);
    }

    protected void ॱᐝ() {
        super.ॱᐝ();
        this.ʼॱ = new d(this);
        IntentFilter intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
        if (this.ʼॱ != null && this.ॱᐝ != null) {
            this.ॱᐝ.registerReceiver(this.ʼॱ, intentFilter);
        }
    }

    protected void ʻॱ() {
        super.ʻॱ();
        if (this.ʼॱ != null && this.ॱᐝ != null) {
            this.ॱᐝ.unregisterReceiver(this.ʼॱ);
        }
    }
}
